package com.gxufl.dao;

import java.util.List;

import com.gxufl.entity.Notice;
import com.gxufl.entity.Room;
import com.gxufl.entity.Seat;
import com.gxufl.entity.Ticket;
import com.gxufl.util.JdbcUtil;

public class TicketDao {

	/**
	 * 查询方法
	 * 
	 * @param name
	 * @param showdate
	 * @return
	 */
	public List<Ticket> findList(String noticeName,String roomName) {
		String sql = "select * from movie_ticket where 1";

		if (noticeName != null && !noticeName.isEmpty()) {
			sql += " and noticename = '" + noticeName + "'";
		}

		if (roomName != null && !roomName.isEmpty()) {
			sql += " and roomname = '" + roomName + "'";
		}

		return JdbcUtil.query(sql, Ticket.class);
	}

	public Ticket save(Ticket ticket) {
		boolean isOK = JdbcUtil.save(ticket);

		if (isOK) {
			System.out.println("售票成功");
		} else {
			System.out.println("售票失败");
		}
		
		return ticket;
	}
	
	public Ticket findOneByUsertel(String usertel) {
		String sql = "select * from movie_ticket where 1 and usertel = '"+usertel+"'";
		return JdbcUtil.queryOne(sql, Ticket.class);
	}

}
